package com.hd.service.activiti.impl;

import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hd.dao.BaseDao;
import com.hd.entity.activiti.UserTaskInfo;
import com.hd.service.activiti.UserTaskInfoService;
@Service("userTaskInfoService")
public class UserTaskInfoServiceImpl implements UserTaskInfoService {
	@Autowired
	private BaseDao<UserTaskInfo,String>userTaskInfoDao;
	@Override
	public void save(UserTaskInfo userTaskInfo) {
		userTaskInfo.setId(UUID.randomUUID().toString());
		userTaskInfoDao.save(userTaskInfo);
	}

	@Override
	public void update(UserTaskInfo userTaskInfo) {
		userTaskInfoDao.update(userTaskInfo);
	}

	@Override
	public UserTaskInfo getByParams(String procDefId, String taskDefKey,String objId) {
		String hql="from UserTaskInfo where 1=1 and procDefId=? and taskDefKey=? and objId=? order by frequency desc";
		List<UserTaskInfo>infos=userTaskInfoDao.find(hql, procDefId,taskDefKey,objId);
		if(infos.size()>0) {
			return infos.get(0);
		}
		return null;
	}
	
	

}
